﻿@{
    ViewBag.Title = "设备图表";
}
<script src="~/Content/highcharts/highcharts.js"></script>
<script src="~/Content/highcharts/highcharts-3d.js"></script>

<div id="sincos" class="center" style="min-width: 600px;height:500px;">
</div>


<script>
    @*$(function () {
        var div='sincos';
        var title='设备资金表';
        var url='@Url.Action("ChartYear", "FactoryMachines")';
        var name='设备资金占比';
        var chart = new Highcharts.Chart({
            chart: {
                renderTo: div,
                type: 'pie',
                options3d: {
                    enabled: true,
                    alpha: 45,
                    beta: 0
                }
            },
            credits: {
                enabled: false},
            title: {
                text: title
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    depth: 35,
                    dataLabels: {
                        enabled: false
                    },
                    showInLegend: true
                }
            },
            series: create(url,name)
        });
    });
    function getdata(url) {
        var data1 = new Array();
        $.ajax({
            type: "POST",
            url: url,
            data: {},
            async: false, //表示同步，如果要得到ajax处理完后台数据后的返回值，最好这样设置
            success: function (result) {


                for (var i in result) {

                    data1.push({ "name": result[i].Name, "y": result[i].Number });
                }

            }

        });

        return data1;
    };


    function create(url, name) {
        var series = new Array();
        series.push({
            type: 'pie',
            name: name,
            data: getdata(url)
        });
        return series;
    };*@
    $(function () {

        show();

    });

    function show() {
        // 图表设置
        var chart = new Highcharts.Chart({
            chart: {
                renderTo: 'sincos',//加载图表到那个id下
                type: 'column',    //图表类型
                margin: 80,        //

                //options3d: {
                //    enabled: true,
                //    alpha: 15,
                //    beta: 15,
                //    depth: 50,
                //    viewDistance: 25   //3d图表设置
                //}
            },
            credits: {
                enabled: false
            },
            xAxis: {
                title: {
                    text: '年度'
                },
                categories: ['2007', '2008', '2009', '2010', '2011', "2012", "2013", "2014", "2015", "2016"]
            },
            yAxis: {
                title: {
                    text: '设备金额'
                }
            },
            title: {
                text: '设备入厂金额表'//主标题
            },

            legend: {              //图例
                enabled : false
            },
            plotOptions: {
                column: {
                    colorByPoint: true
                }
            },
            exporting: {
                enabled: false //是否可以导出
            },
            series: create()
        });


    }


    function create() {
        var series = new Array();
        $.ajax({
            type: "POST",
            url: '@Url.Action("ChartYearPrice", "FactoryMachines")',
            data: {},
            async: false, //表示同步，如果要得到ajax处理完后台数据后的返回值，最好这样设置
            success: function (result) {

                    series.push({ "name": result.Name, "data": result.Data });

            }

        }, true);

        return series;
    }





</script>

